DELETE ServiceEngine.RuntimeServers_Endpoints
DELETE ServiceEngine.RuntimeServers
DELETE ServiceEngine.EndPoints
DELETE ServiceEngine.OperationVersions
DELETE ServiceEngine.Operations
DELETE ServiceEngine.EndPoints_AssociatedOperations
DELETE ServiceEngine.EndPoints_PublishedOperations
DELETE ServiceEngine.Operations_OperationGroups
DELETE ServiceEngine.OperationGroups
DELETE ServiceEngine.Policies
DELETE ServiceEngine.Names
DELETE ServiceEngine.Schemas
DELETE ServiceEngine.MessageParts
DELETE ServiceEngine.Channels
DELETE ServiceEngine.Bindings
go

DECLARE @RC int
DECLARE @Name nvarchar(400)
DECLARE @BindingConfig xml
DECLARE @Description nvarchar(400)
DECLARE @ID uniqueidentifier

-- MSE System EndPoint Bindings
set @Name='BasicHttp (Soap11)'
set @BindingConfig = N'<bindings xmlns="">
  <basicHttpBinding>
    <binding name="basicHttp" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
      <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
      <security mode="None">
        <transport clientCredentialType="None" proxyCredentialType="None" realm="" />
        <message clientCredentialType="UserName" algorithmSuite="Default" />
      </security>
    </binding>
  </basicHttpBinding>
</bindings>'
set @Description = N'BasicHttp Binding with Soap11 Message Version. Please do not modify or delete as this is a system generated Binding used by different MSE system modules.'
set @ID = '{00000000-0000-0000-0000-B00000000001}'

EXECUTE @RC = [MSE6DB].[ServiceEngine].[CreateBinding] 
   @Name
  ,@BindingConfig
  ,@Description
  ,@ID OUTPUT


set @Name='BasicHttp (Soap12)'
set @BindingConfig = N'<bindings xmlns="">
  <customBinding>
    <binding name="svcSoap12">
      <textMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16" messageVersion="Soap12" writeEncoding="utf-8">
        <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
      </textMessageEncoding>
      <httpTransport manualAddressing="false" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" allowCookies="false" authenticationScheme="Anonymous" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" keepAliveEnabled="true" maxBufferSize="65536" proxyAuthenticationScheme="Anonymous" realm="" transferMode="Buffered" unsafeConnectionNtlmAuthentication="false" useDefaultWebProxy="true" />
    </binding>
  </customBinding>
</bindings>'
set @Description = N'BasicHttp Binding with Soap12 Message Version. Please do not modify or delete as this is a system generated Binding used by different MSE system modules.'
set @ID = '{00000000-0000-0000-0000-B00000000002}'

EXECUTE @RC = [MSE6DB].[ServiceEngine].[CreateBinding] 
   @Name
  ,@BindingConfig
  ,@Description
  ,@ID OUTPUT


set @Name='WsHttp (Soap12)'
set @BindingConfig = N'<bindings xmlns="">
  <wsHttpBinding>
    <binding name="wsHttp" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
      <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
      <reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" />
      <security mode="Message">
        <transport clientCredentialType="Windows" proxyCredentialType="None" realm="" />
        <message clientCredentialType="Windows" negotiateServiceCredential="true" algorithmSuite="Default" establishSecurityContext="true" />
      </security>
    </binding>
  </wsHttpBinding>
</bindings>'
set @Description = N'WsHttp Binding with Soap12 Message Version. Please do not modify or delete as this is a system generated Binding used by different MSE system modules.'
set @ID = '{00000000-0000-0000-0000-B00000000003}'

EXECUTE @RC = [MSE6DB].[ServiceEngine].[CreateBinding] 
   @Name
  ,@BindingConfig
  ,@Description
  ,@ID OUTPUT


set @Name='NetNamedPipe'
set @BindingConfig = N'<bindings xmlns="">
  <netNamedPipeBinding>
    <binding name="NetPipe" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxBufferSize="65536" maxConnections="10" maxReceivedMessageSize="65536">
      <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
      <security mode="Transport">
        <transport protectionLevel="EncryptAndSign" />
      </security>
    </binding>
  </netNamedPipeBinding>
</bindings>'
set @Description = 'NetNamedPipe Binding. Please do not modify or delete as this is a system generated Binding used by different MSE system modules.'
set @ID = '{00000000-0000-0000-0000-B00000000004}'

EXECUTE @RC = [MSE6DB].[ServiceEngine].[CreateBinding] 
   @Name
  ,@BindingConfig
  ,@Description
  ,@ID OUTPUT


set @Name='NetTcp'
set @BindingConfig = N'<bindings xmlns="">
  <netTcpBinding>
    <binding name="netTcp" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions" hostNameComparisonMode="StrongWildcard" listenBacklog="10" maxBufferPoolSize="524288" maxBufferSize="65536" maxConnections="10" maxReceivedMessageSize="65536">
      <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
      <reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" />
      <security mode="Transport">
        <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
        <message clientCredentialType="Windows" />
      </security>
    </binding>
  </netTcpBinding>
</bindings>'
set @Description = 'NetTcp Binding. Please do not modify or delete as this is a system generated Binding used by different MSE system modules.'
set @ID = '{00000000-0000-0000-0000-B00000000005}'

EXECUTE @RC = [MSE6DB].[ServiceEngine].[CreateBinding] 
   @Name
  ,@BindingConfig
  ,@Description
  ,@ID OUTPUT


set @Name='POX'
set @BindingConfig = N'<bindings xmlns="">
  <customBinding>
    <binding name="poxBinding">
      <textMessageEncoding messageVersion="None">
      </textMessageEncoding>
      <httpTransport manualAddressing="false" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" allowCookies="false" authenticationScheme="Anonymous" bypassProxyOnLocal="false" keepAliveEnabled="true" hostNameComparisonMode="StrongWildcard" maxBufferSize="65536" proxyAuthenticationScheme="Anonymous" realm="" transferMode="Buffered" unsafeConnectionNtlmAuthentication="false" useDefaultWebProxy="true">
      </httpTransport>
    </binding>
  </customBinding>
</bindings>'
set @Description = 'POX (Plain Old XML) Binding. Please do not modify or delete as this is a system generated Binding used by different MSE system modules.'
set @ID = '{00000000-0000-0000-0000-B00000000006}'

EXECUTE @RC = [MSE6DB].[ServiceEngine].[CreateBinding] 
   @Name
  ,@BindingConfig
  ,@Description
  ,@ID OUTPUT



DECLARE @PolicyXml xml

set @Name='Turn off MetaData Publishing'
set @PolicyXml = N'<PolicyModel xmlns="http://microsoft.com/mse/2007/runtime/policyModel" xmlns:mse="http://services.microsoft.com/MSE" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:wcf="clr-namespace:System.ServiceModel.Configuration;assembly=System.ServiceModel">
  <wcf:ServiceMetadataPublishingElement HttpGetEnabled="false" HttpGetUrl="/">
  </wcf:ServiceMetadataPublishingElement>
</PolicyModel>'
set @Description = N'This policy can be used to disable metadata publishing at an endpoint.'
set @ID = '{00000000-0000-0000-0000-A00000000001}'

EXECUTE @RC = [MSE6DB].[ServiceEngine].[CreatePolicy] 
   @Name
  ,@PolicyXml
  ,@Description
  ,@ID OUTPUT



set @Name='WCF Throttling Override'
set @PolicyXml = N'<PolicyModel xmlns="http://microsoft.com/mse/2007/runtime/policyModel" xmlns:mse="http://services.microsoft.com/MSE" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:wcf="clr-namespace:System.ServiceModel.Configuration;assembly=System.ServiceModel">
  <wcf:ServiceThrottlingElement MaxConcurrentCalls="10" MaxConcurrentSessions="10" MaxConcurrentInstances="2">
  </wcf:ServiceThrottlingElement>
</PolicyModel>'
set @Description = N'This policy can be used to tweak the WCF throttling configuration at an endpoint.'
set @ID = '{00000000-0000-0000-0000-A00000000002}'

EXECUTE @RC = [MSE6DB].[ServiceEngine].[CreatePolicy] 
   @Name
  ,@PolicyXml
  ,@Description
  ,@ID OUTPUT


set @Name='RegEx Filter'
set @PolicyXml = N'<PolicyModel xmlns="http://microsoft.com/mse/2007/runtime/policyModel" xmlns:mse="http://services.microsoft.com/MSE" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:wcf="clr-namespace:System.ServiceModel.Configuration;assembly=System.ServiceModel" xmlns:regEx="clr-namespace:RegExContentFilter;assembly=RegExContentFilter">
  <regEx:RegExContentBehaviorExtensionElement>
    <regEx:RegPatternItem>
      <regEx:RegPatternItem.Key>AddTwoDoublesResult</regEx:RegPatternItem.Key>
      <regEx:RegPatternItem.Pattern>sum</regEx:RegPatternItem.Pattern>
    </regEx:RegPatternItem>   
  </regEx:RegExContentBehaviorExtensionElement> 
</PolicyModel>'
set @Description = N'This policy can be used to enable Regular Expression filtering across messages.'
set @ID = '{00000000-0000-0000-0000-A00000000003}'

EXECUTE @RC = [MSE6DB].[ServiceEngine].[CreatePolicy] 
   @Name
  ,@PolicyXml
  ,@Description
  ,@ID OUTPUT


DECLARE	@return_value int

EXEC	@return_value = [ServiceEngine].[CreateSchema]
		@Name = N'http://schemas.microsoft.com/2003/10/Serialization/',
		@Schema = N'<xs:schema elementFormDefault="qualified" attributeFormDefault="qualified" xmlns:tns="http://schemas.microsoft.com/2003/10/Serialization/" targetNamespace="http://schemas.microsoft.com/2003/10/Serialization/" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="anyType" nillable="true" type="xs:anyType" />
  <xs:element name="anyURI" nillable="true" type="xs:anyURI" />
  <xs:element name="base64Binary" nillable="true" type="xs:base64Binary" />
  <xs:element name="boolean" nillable="true" type="xs:boolean" />
  <xs:element name="byte" nillable="true" type="xs:byte" />
  <xs:element name="dateTime" nillable="true" type="xs:dateTime" />
  <xs:element name="decimal" nillable="true" type="xs:decimal" />
  <xs:element name="double" nillable="true" type="xs:double" />
  <xs:element name="float" nillable="true" type="xs:float" />
  <xs:element name="int" nillable="true" type="xs:int" />
  <xs:element name="long" nillable="true" type="xs:long" />
  <xs:element name="QName" nillable="true" type="xs:QName" />
  <xs:element name="short" nillable="true" type="xs:short" />
  <xs:element name="string" nillable="true" type="xs:string" />
  <xs:element name="unsignedByte" nillable="true" type="xs:unsignedByte" />
  <xs:element name="unsignedInt" nillable="true" type="xs:unsignedInt" />
  <xs:element name="unsignedLong" nillable="true" type="xs:unsignedLong" />
  <xs:element name="unsignedShort" nillable="true" type="xs:unsignedShort" />
  <xs:element name="char" nillable="true" type="tns:char" />
  <xs:simpleType name="char">
    <xs:restriction base="xs:int"/>
  </xs:simpleType>  
  <xs:element name="duration" nillable="true" type="tns:duration" />
  <xs:simpleType name="duration">
    <xs:restriction base="xs:duration">
      <xs:pattern value="\-?P(\d*D)?(T(\d*H)?(\d*M)?(\d*(\.\d*)?S)?)?" />
      <xs:minInclusive value="-P10675199DT2H48M5.4775808S" />
      <xs:maxInclusive value="P10675199DT2H48M5.4775807S" />
    </xs:restriction>
  </xs:simpleType>
  <xs:element name="guid" nillable="true" type="tns:guid" />
  <xs:simpleType name="guid">
    <xs:restriction base="xs:string">
      <xs:pattern value="[\da-fA-F]{8}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{12}" />
    </xs:restriction>
  </xs:simpleType>
  <xs:attribute name="FactoryType" type="xs:QName" />
</xs:schema>',
		@PreferredPrefix = N'xx1',
		@ID = @ID OUTPUT
		
		
EXEC	@return_value = [ServiceEngine].[CreateSchema]
		@Name = N'http://schemas.microsoft.com/2003/10/Serialization/Arrays',
		@Schema = N'<xs:schema xmlns:tns="http://schemas.microsoft.com/2003/10/Serialization/Arrays" elementFormDefault="qualified" targetNamespace="http://schemas.microsoft.com/2003/10/Serialization/Arrays" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:complexType name="ArrayOfanyType">
    <xs:sequence>
      <xs:element minOccurs="0" maxOccurs="unbounded" name="anyType" nillable="true" type="xs:anyType" />
    </xs:sequence>
  </xs:complexType>
  <xs:element name="ArrayOfanyType" nillable="true" type="tns:ArrayOfanyType" />
</xs:schema>',
		@PreferredPrefix = N'xx1',
		@ID = @ID OUTPUT
		
		

